var tabsQuyHoach = function()
{
	this.divMapBandoQuyhoach = 'div_Map_Bandoquyhoach_Info_TABs';
	this.divMapBandoQuyhoachChung = 'div_Map_Bandoquyhoach_Info_CHUNG';
	this.divMapBandoQuyhoachChitiet = 'div_Map_Bandoquyhoach_Info_CHITIET';
	this.typeQuyhoachActive = 1; // 1: quy hoach chung - 2: quy hoach chi tiet
	$('#' + this.divMapBandoQuyhoach + ' ul li a').mousedown(function() {
		var sHref = this.href;
		if(sHref.indexOf(tabsQuyHoachObj.divMapBandoQuyhoachChung) != -1) tabsQuyHoachObj.typeQuyhoachActive = 1;
		else 
		{
			assetQHCHITIET.MaQHChung = assetQHCHUNG.MaQHChung;
			tabsQuyHoachObj.typeQuyhoachActive = 2;
			if(actionCurrent == PortletTypeAction.Edit)
			{
				// lay feature current ung voi ma quy hoach chi tiet				
				var layerName = assetQHCHITIET.layerName;
				var objVectorLayer = LayerTool.getVectorLayer(layerName);
		 		var indexLayer = objVectorLayer.IndexLayer;
		 		var objLayer = map.layers[indexLayer];

				var sMaQHChitiet_FID = $('#select_QHCHITIET_QHChiTiet').val();
				featureCurrentAction = objLayer.getFeatureByFid(sMaQHChitiet_FID);
				//getFeaturesByAttribute(assetQHCHITIET.MaVungQGChitietField, sMaQHChitiet);
				//if(arrFeaturQHChung.length == 0) featureCurrentAction = null;
				//featureCurrentAction = arrFeaturQHChung[0];
		 		vectorGraphics.removeAllFeatures();
				createPolygonFromGeometry(vectorGraphics, featureCurrentAction.geometry);
			}
		}
	});

	// bActiveChung: true - active quy hoach chung - false - active quy hhoach chi tiet
	this.tabQuyhoachActive = function(bActiveChung)
	{
		 var $itemQuyHoachTabs = $('#' + this.divMapBandoQuyhoach).find('.item');
		 $ulTab = $itemQuyHoachTabs[0];
		 // quy hoach chung
		 var itemQHChung = $($ulTab).find('li')[0];
		 // quy hoach chi tiet
		 var itemQHChiTiet = $($ulTab).find('li')[1];
		 
		 if(bActiveChung) // chuyen sang tab QH chung
		 {
			 // an quy hoach chi tiet
			 $(itemQHChiTiet).removeClass('current');
			 $($(itemQHChiTiet).find('a').attr('href')).hide();
			 // hien quy hoach chung
			 if(!$(itemQHChung).hasClass('current')) $(itemQHChung).addClass('current');
			 $($(itemQHChung).find('a').attr('href')).fadeIn();		
			 this.typeQuyhoachActive = 1;
		 }
		 else // chuyen sang quy hoach chi tiet
		 { 		 
			 // an quy hoach chung
			 $(itemQHChung).removeClass('current');
			 $($(itemQHChung).find('a').attr('href')).hide();
			 // hien quy hoach chi tiet
			 $(itemQHChiTiet).addClass('current');
			 $($(itemQHChiTiet).find('a').attr('href')).fadeIn(); 		
			 this.typeQuyhoachActive = 2;
		 }
	};	
	
	// lay tai san la vung quy hoach chung hoac chi tiet ung vois tabs duoc active
	this.getVungQuyHoach = function()
	{
		var obj = null;
		var $vungQH = $('#' + this.divMapBandoQuyhoach  + ' ul li');
		var i=0;
		for(i = 0; i<$vungQH.length; i++)
		{
			$liVungQH = $($vungQH[i]);
			if($liVungQH.hasClass('current'))
			{
				if(i == 0) obj = assetQHCHUNG;
				else obj = assetQHCHITIET;
			}
		}
		return obj;
	};
};

var tabsQuyHoachObj = new tabsQuyHoach();